package com.zl.learning.regex;

import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexMatches {

    @Test
    public void test1() {
        final String REGEX = "cat";
        final String INPUT = "cat cat cat cattie cat";

        Matcher m = Pattern.compile(REGEX).matcher(INPUT); // 获取 matcher 对象
        int count = 0;
        while (m.find()) {
            count++;
            System.out.println("Match number " + count);
            System.out.println("start(): " + m.start());
            System.out.println("end(): " + m.end());
        }
    }

    @Test
    public void test12() {
        String url = "https://etherscan.io/token/generic-tokentxns2?contractAddress=0xf85feea2fdd81d51177f6b8f35f0e6734ce45f5f&mode=&a=0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be&p=1";
        String reg = "g\\w+-+\\w+2\\?";
        String reg2 = "=(\\w+)&";
        Matcher m = Pattern.compile(reg).matcher(url); // 获取 matcher 对象
        while (m.find()) {
            System.out.println(m.group(0));
        }
//        System.out.println(m.group());
    }
}
